<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>用户授权管理</title>
<link rel="stylesheet" type="text/css" href="../../css/reset.css" />
<link rel="stylesheet" type="text/css" href="../../css/css.css" />
<link rel="stylesheet" type="text/css"
	href="../../js/jquery-easyui-1.4.3/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="../../js/jquery-easyui-1.4.3/themes/icon.css" />
<link rel="stylesheet" type="text/css"
	href="../../js/SimpleTree1.3/js/tree_themes/SimpleTree.css" />
<link rel="stylesheet" type="text/css" href="../../css/colorReset.css" />



<style type="text/css">
.popup_con {
	border: 1px solid #95B8E7;
	width: 380px;
	margin: 10px auto 0 auto;
}

.popup_con ul {
	margin: 10px auto;
	width: 380px;
	overflow: hidden;
}

.popup_con ul li {
	width: 340px;
	display: block;
	float: left;
	height: 25px;
	overflow: hidden;
	padding: 5px 0;
}

.popup_con ul li.li_col {
	width: 380px;
	height: auto;
}

.popup_con .text {
	width: 200px;
}

.tree_con {
	height: 270px;
	overflow: auto;
	margin: 0 auto;
	padding-top: 5px;
}

#system_show .tree_con {
	height: 305px;
}

.search-con {
	width: 100%;;
	background: #f0fbff;
	border-bottom: 1px solid #d1d8de;
	padding: 5px 0;
	margin: 0;
	line-height: 26px;
}

.search-con .text {
	width: 110px;
	height: 20px;
	line-height: 20px;
	border-radius: 0;
}

.search-con button {
	display: inline;
}

input[readonly='readonly'] {
	background: #fff;
}
</style>

</head>

<body>

	<div class="main">
		<!-- 检索区域开始 -->
		<div class="sel_div">
			<table cellpadding="0" cellspacing="0" class="sel_con">
				<tr>
					<th colspan="5">数据检索</th>
				</tr>
				<tr>
					<td><label>账号：</label> <input id="searchUserCode"
						name="searchUserCode" class="text" /></td>

					<td><label>姓名：</label> <input class="text" type="text"
						name="searchUserName" id="searchUserName" /></td>
					<td><label>所属角色：</label> <input class="text" type="text"
						name="comboxRole" id="comboxRole" /></td>
					<!--  <td>&nbsp;
        
        </td> -->
					<td>
						<button class="query_btn easyui-linkbutton" iconCls="icon-search"
							onclick="onSearch()">查询</button>
					</td>

					<td>
						<button class="query_btn easyui-linkbutton" iconCls="icon-reset"
							onclick="onReset()">重置</button>
					</td>
				</tr>
			</table>
		</div>

		<!-- 检索区域结束 -->
		<div class="data_con">
			<table id="datagrid" style="height: 300px"
				data-options="fitColumns:true,toolbar:'#toolbox'">
			</table>
		</div>
		<!--选择所属系统-->
		<div class="easyui-window" id="system_selection" title="系统选择">
			<div class="search-con">
				<label for="systemName" style="margin-left: 15px;">名称：</label> <input
					id="systemName" name="systemName" class="text" style="width: 98px;" />
				<button id="searchNode" name="searchNode" style="width: 50px;"
					class="default_btn">定位</button>
				<button id="ensureSelect" name="ensureSelect" style="width: 50px;"
					class="default_btn">确定</button>
			</div>
			<div class="tree_con">
				<ul id="tt"></ul>
			</div>
		</div>
		<!--查看所属系统-->
		<div class="easyui-window" id="system_show" title="接口选择">
			<div class="tree_con">
				<ul id="sys_show_tt"></ul>
			</div>
		</div>
		<div id="winEdit" class="easyui-window" title="用户授权"
			style="width: 430px; height: auto; top: 20px"
			data-options="iconCls:'icon-save',modal:true,minimizable:false,maximizable:false,collapsible:false">
			<form id="authForm" method="post">
				<div class="popup_con">

					<ul>
						<li class="li_col"><label for="userCode" class="label">账号：</label>
							<div class="input_con">
								<input id="userId" name="userId" type="hidden" /> <input
									id="userCode" name="userCode" class="text" readonly="readonly" />
							</div></li>
						<li class="li_col"><label for="assignedRoles" class="label">分配角色：</label>
							<div class="input_con">
								<input class="text" type="text" name="assignedRoles"
									id="assignedRoles" />
							</div></li>
						<li class="li_col"><label for="system" class="label">所属系统：</label>
							<div class="input_con">
								<input id="strFieldSystems" name="strFieldSystems" type="hidden" />
								<input id="system" name="system" type="text" class="text"
									readonly="readonly" />
								<button style="width: 50px; display: inline" class="default_btn"
									id="selSystemBtn">选择</button>
							</div></li>
						<li class="li_col"><label for="remark" class="label">备&nbsp;&nbsp;注：</label>
							<div class="input_con">
								<textarea id="remark" name="remark" rows="4"
									style="width: 200px; padding: 3px;" class="easyui-validatebox"
									data-options="validType:'maxLength[100]'"></textarea>

							</div></li>
					</ul>
				</div>
			</form>
			<div id="buttons" class="button_con">
				<a href="javascript:void(0)" onclick="onSave()"
					class="easyui-linkbutton" id="instance_save" iconCls="icon-ok"
					plain="true">保存</a> <a href="javascript:void(0)"
					onclick="onCancleEdit()" class="easyui-linkbutton" id="cancal"
					iconCls="icon-cancel" plain="true">取消</a>
			</div>
		</div>
	</div>

	<script type="text/javascript" src="/webjars/json3/3.3.2/json3.min.js"></script>
	<script type="text/javascript"
		src="../../js/jquery-easyui-1.4.3/jquery.min.js"></script>
	<script type="text/javascript"
		src="../../js/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
	<script type="text/javascript"
		src="../../js/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"></script>

	<script type="text/javascript" src="../../js/cook/constants.js"></script>
	<script type="text/javascript" src="../../js/cook/FormValidate.js"></script>
	<script type="text/javascript" src="../../js/cook/public.js"></script>
	<script>
var modifyOrAddFlag;
//定位显示
var arrayLi = [];
var arrayLiInd = 0;
//var fieldSystems=null;//保存获取的领域系统集合(减少访问数据库次数)
var treeData=null;//树结构数据
var g_currSystemsStr = "";
//初始化数据
$(document).ready(function(){
		
		$('#winEdit').window('close');
		//接口选择
		$('#system_selection').window({
			width:310,
			height:355,
			modal:true,
			minimizable:false,
			maximizable:false,
			collapsible:false,
			onClose: function () {
				$("#tt").html("");
			}
		});
		$('#system_selection').window('close');  //关闭窗口
		
		//查看系统
		$('#system_show').window({
			width:260,
			height:355,
			modal:true,
			title:"所属系统",
			minimizable:false,
			maximizable:false,
			collapsible:false
		});
		$('#system_show').window('close');  //关闭窗口
		
		$(".button_con a" ).removeClass("l-btn-plain");
		
		var urlParamObj = getParamobjFromUrl();
		var authState = urlParamObj.authState;
		$('#comboxRole').combobox({
			editable: false,
			url: BASE_URL_ROLES + '?v=' + Date.parse(new Date()),
			valueField: 'id',
		    textField: 'roleName',
		    method:'get',
			onSelect: function(record) {
				$("#comboxRole").val(record.id);
				authState = "";
				//console.log(record);
			},
		    loadFilter:function(data){
		    	data._embedded.roles.unshift({'id':'unAuthorized','roleName':'未授权',"selected":authState == "unAuthorized"? true:false});
		    	data._embedded.roles.unshift({'id':'','roleName':'全部','selected':authState == "unAuthorized"? false:true});
				authState=null;
		    	return data._embedded.roles;
		    },
			onLoadSuccess: function() {
				
			}
		});
		$("#datagrid").datagrid({
			url : BASE_URL_USER_SEARCH +'/findByExample?v=' + Date.parse(new Date()),
			method:'get',
			nowrap:false,
			autoRowHeight:true,//自动行高
			singleSelect: true,//单选
			pagination:true,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						{field:'handle',title:'操作',width:60,  formatter: function(value, rowData, rowIndex){
								return '<a href="javascript:void(0)" class="default_btn" onclick="onOpenEdit(' + rowIndex + ');">分配</a>';
							}
						},
						{field:'userCode',title:'账号',width:100,align:'left'},
						{field:'roleName',title:'所属角色',width:100, formatter: function(value, rowData, rowIndex){
								return !value?"未授权":value;
							}
						},
						{field:'fieldSystemCount',title:'所属系统数',width:100, formatter: function(value, rowData, rowIndex){
								return value == 0? "未分配":'<a href="javascript:void(0);" class="default_btn" onclick="onShowDetail(' + rowIndex + ');" title="点击查看详情">' + value + '</a>';
							}
						},
						{field:'userName',title:'姓名',width:100,align:'left'},
						{field:'empNo',title:'工号',width:100},
						{field:'remark',title:'备注',width:300,align:'left', formatter: function(value, rowData, rowIndex){
								return value;
							}
						}
			      ]],
			loadFilter:function(data){
				return {
					total: data.totalElements,
					rows: data.content
				};
			},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				param.sort = 'createTime,desc';
				delete param.rows;
				
				var roleId = $("#comboxRole").combobox("getValue");
				if(authState == "unAuthorized")
				{
					param["grantStatus"] = authState;
				}
				
				if(roleId == "unAuthorized")
				{
					param["grantStatus"] = roleId;
				}
				else
				{
					param["roleId"] = roleId;
				}
				
				param["userCode"] = $("#searchUserCode").val();
				param["userName"] = $("#searchUserName").val();
			}
		});
		
		$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		}); 

		$('#assignedRoles').combobox({
			editable: false,
			url: BASE_URL_ROLES + '?v=' + Date.parse(new Date()),
			valueField: 'id',
		    textField: 'roleName',
		    method:'get',
			onSelect: function(record) {
				$("#assignedRoles").val(record.id);
				if(record.id == "0") //管理员角色，默认拥有所有系统
				{
					$("#selSystemBtn").fadeOut();
					$("#system").val("管理员拥有所有系统");
				}
				else
				{
					$("#selSystemBtn").fadeIn();
					$("#system").val(g_currSystemsStr);
				}
				//console.log(record);
			},
		    loadFilter:function(data){
		    	return data._embedded.roles;
		    },
			onLoadSuccess: function() {
				if(!$("#assignedRoles").val())
				{
					var dataList = $("#assignedRoles").combobox("getData");
					var defaultId = dataList[0].id;
					for(var i = 0; i < dataList.length; ++i)
					{
						if(dataList[i].roleName == "接口运维者")
						{
							defaultId = dataList[i].id;
							break;
						}
					}
					$("#assignedRoles").combobox("select",defaultId);
				}
				else
				{
					$("#assignedRoles").combobox("select",$("#assignedRoles").val());
				}
			}
		});
		

		$("#sys_show_tt").tree({
			lines:false,
			data:[]
		});
		
		
		$("#selSystemBtn").click(function(e) {
			//if(treeData==null){
				$("#tt").tree({
					url:BASE_URL_TREE + '/getFieldSystemsForEasyUiTree' + '?v=' + Math.random(),
					method: "get",
					lines:false,
					async:false,
					checkbox: true,
					loadFilter: function(data,parent) {
						treeData = [{text:"全部", children:data, nodeType:"root"}];
						return treeData;
					},
					onLoadSuccess:function()
					{
						$("#tt > li > ul > li > ul > li > .tree-node > .tree-file").css("background","url('../../images/st_folder.png') no-repeat 2px 2px");
						$("#tt > li > ul > li > .tree-node > .tree-file").parent().parent().css("display","none");
						reSetTree();
					},
					onClick:function(node){
						if(node.checked)
						{
							$("#tt").tree("uncheck", node.target);
						}
						else
						{
							$("#tt").tree("check", node.target);
						}
						
						//$("#systemName").val(node.text);
						//choose_tree();
					}
				});
			//}else{
				//reSetTree()
			//}
			
			
			return false;
		});
		
		
		
		$("#ensureSelect").click(function (e) {
			var checkedNodes = $("#tt").tree("getChecked");
			var selectSystems = "";
			var systemsName = "";
			for(var i = 0, len = checkedNodes.length; i < len; ++i)
			{
				var tempNode = checkedNodes[i];
				if(tempNode.nodeType != "fieldSystem")
				{
					continue;
				}
				selectSystems += (selectSystems != ""? ",":"") + tempNode.id;
				systemsName += (systemsName != ""? ",":"") + tempNode.text;
			}
			$("#strFieldSystems").val(selectSystems);
			$("#system").val(systemsName);
			$('#system_selection').window('close');	
		});

		$("#searchNode").click(function (e) { 
			if($("#systemName").val() != '')
			{
				choose_tree();
			}
			else
			{
				$(".systemName").val("");
				var row = $('#tt li .tree-node');  
				row.removeClass('tree-node-selected');
				$(".tree_con").scrollTop(0);
			}
		});  
		$("#systemName").bind('input propertychange', function() {
			arrayLi = [];
			arrayLiInd = 0;
			if($("#systemName").val() != '')
			{
				choose_tree();
			}else
			{
				$("#ff input").val("");
				var row = $('#tt li .tree-node');  
				row.removeClass('tree-node-selected');
				$(".tree_con").scrollTop(0);
			}
		});
		$(document , "#systemName").keyup(function(event){
		  if(event.keyCode == 8){
		    $("#searchNode").trigger("click");
		  }
		});
		$(document , "#systemName").keyup(function(event){
		  if(event.keyCode ==13){
		    $("#searchNode").trigger("click");
		  }
		});
		
});


	function reSetTree(){
		$('#system_selection').window('open');	
		var txtInterface = $("#system").val().split(",")[0];
	
		if(txtInterface !== '')
		{
			$("#systemName").val(txtInterface);
			choose_tree();
		}
		else
		{
			$("#systemName").val('');
			$(".tree_con").scrollTop(0);
			var row = $('#tt li .tree-node');  
			row.removeClass('tree-node-selected');
		}
		
		var checkedNodes = $("#tt").tree("getChecked");
		if(checkedNodes)
		{
			$.each(checkedNodes, function(index, node) {
				$("#tt").tree("uncheck", node.target);
			});
		}
		
		var currSystemsStr = $("#system").val();
		if(currSystemsStr != '')
		{
			setCheckedList(currSystemsStr.split(","));
		}
	}

	function onSave()
	{
		if($("#authForm").form("validate")){
			$("#instance_save").linkbutton("disable");
			$("#instance_save .l-btn-text").text("提交中...");
			var row = $('#datagrid').datagrid('getSelected');
			var newUserInfoJSON = {};
			newUserInfoJSON["roleId"] = $('#assignedRoles').combobox("getValue");
			var fieldSystemsStr = $("#strFieldSystems").val();
			newUserInfoJSON["fieldSystemIds"] = fieldSystemsStr == ""? []:fieldSystemsStr.split(",");
			newUserInfoJSON["remark"] = $("#remark").val();
			newUserInfoJSON["id"] = $("#userId").val();
			$.ajax({
				type: "post",
				url: BASE_URL_USER_CRUD + "/assignRoleAndSystem",
				data: JSON.stringify(newUserInfoJSON),
				contentType: "application/json",
				success: function(result) {
					$("#instance_save").linkbutton("enable");
					$("#instance_save .l-btn-text").text("保存");
					if(result.backValue === true)
					{
						$('#winEdit').window('close');  //关闭窗口
						$.messager.alert('提示','<p>修改用户授权信息成功!</p>', 'info');
						$("#datagrid").datagrid("reload", BASE_URL_USER_SEARCH + '/findByExample?v=' + Date.parse(new Date()));
						
					}
					else
					{
						$.messager.alert('错误', '<p>' + result.backValue + '</p>','error');
					}
				},
				error: function() {
					$("#instance_save").linkbutton("enable");
					$("#instance_save .l-btn-text").text("保存");
					$.messager.alert('错误','<p>服务异常，修改用户授权信息失败，请稍后重试!</p>','error');
				}
			});
		};
	}
	
	//点击分配打开用户授权修改页面
	function onOpenEdit(rowIndex) {
		var rowData = $('#datagrid').datagrid('getRows')[parseInt(rowIndex, 10)];
		$.ajax({
			type: "get",
			url: BASE_URL_USER_SEARCH + "/getFieldSystemRoot?id="+rowData.id,
			dataType:"json",/* 
			async:false, */
			contentType: "application/json",
			success: function(data) {
				//fieldSystems = data;
				reBackData(rowData,data);
			},
			error: function() {
				$.messager.alert('错误','<p>服务异常，修改用户授权信息失败，请稍后重试!</p>','error');
			}
		});	
		
	}
	
	//点击分配后要回显用户相关数据
	function reBackData(rowData,data){
		$("#userId").val(rowData.id);
		$("#userCode").val(rowData.userCode);
		var systemsInfo = getSystemsStrFromSyslist(data);
		g_currSystemsStr = systemsInfo.names;
		$("#strFieldSystems").val(systemsInfo.ids);
		$("#system").val(systemsInfo.names);
		$("#remark").val(rowData.remark);

		$('#assignedRoles').combobox('clear');
		if(window.parent.g_currUserCode == rowData.userCode && rowData.roleId == "0")
		{
			$('#assignedRoles').combobox({
				disabled: true,
				onBeforeLoad: function() {
					$("#assignedRoles").val(rowData.roleId);
				},
				url: BASE_URL_ROLES + '?v=' + Date.parse(new Date())
			});
		}
		else
		{
			$('#assignedRoles').combobox({
				disabled: false,
				onBeforeLoad: function() {
					$("#assignedRoles").val(rowData.roleId);
				},
				url: BASE_URL_ROLES + '?v=' + Date.parse(new Date())
			});
		}
		
		$("#authForm").form("validate");
		$('#winEdit').window('open');
	}

	function onCancleEdit(){
		$('#winEdit').window('close');
	}
	
	function onSearch(){
		$('#datagrid').datagrid('load');
	}
	
	//通过领域系统对象数组转成系统字符串
	function getSystemsStrFromSyslist(fieldSystemsArr) {
		var systemsStr = "";
		var systemIdsStr = "";
		for(var i = 0, len=fieldSystemsArr.length; i < len; ++i)
		{
			if(!fieldSystemsArr[i])
			{
				continue;
			}
			var fieldName = fieldSystemsArr[i].fieldName;
			var systemName = fieldSystemsArr[i].fieldSystemName;
			systemIdsStr += (systemIdsStr == ""? "":",") + fieldSystemsArr[i].fieldSystemId;
			systemsStr += systemName + (i == len-1? "":",");
		}
		return {
			ids:systemIdsStr,
			names:systemsStr
		};
	}
	
	//通过字符串获取系统列表
	function getSystemListFromStr(fieldSystemsStr) {
		if(!fieldSystemsStr)
		{
			return [];
		}
		var fieldSystemList = fieldSystemsStr.split(",");
		var systemList = [];
		for(var i = 0, len=fieldSystemList.length; i < len; ++i)
		{
			if(!fieldSystemList[i])
			{
				continue;
			}
			var systemName = fieldSystemList[i].split("-")[1];
			if(systemName)
			{
				systemList.push(systemName);
			}
		}
		return systemList;
	}

	//通过字符串获取构造领域系统的树节点信息
	function getFieldSystemNodesFromStr(fieldSystemsStr) {
		if(!fieldSystemsStr)
		{
			return [];
		}
		var fieldSystemList = fieldSystemsStr.split(",");
		var fieldList = [];
		var systemNodeList = [];
		for(var i = 0, len=fieldSystemList.length; i < len; ++i)
		{
			if(!fieldSystemList[i])
			{
				continue;
			}
			var fieldName = fieldSystemList[i].split("-")[0];
			var systemName = fieldSystemList[i].split("-")[1];
			if(fieldName)
			{
				var tempNode = {};
				var j = 0;
				for(; j < fieldList.length; ++j)
				{
					if(fieldList[j].text == fieldName)
					{
						if(systemName)
						{
							fieldList[j].children.push({
								text:systemName,
								children:[],
								nodeType:"fieldSystem"
							});
						}
						break;
					}
				}
				if(j == fieldList.length)
				{
					tempNode.text = fieldName;
					tempNode.nodeType = "field";
					tempNode.children = [];
					if(systemName)
					{
						tempNode.children.push({
							text:systemName,
							children:[],
							nodeType:"fieldSystem"
						});
					}
					fieldList.push(tempNode);
				}
			}
			
		}
		return fieldList;
	}
	
	//通过领域系统对象数组转换成树节点信息
	function getFieldSystemNodesFromArr(fieldSystemsArr) {
		if(!fieldSystemsArr)
		{
			return [];
		}
		var fieldNodes = [];
		for(var i = 0, len=fieldSystemsArr.length; i < len; ++i)
		{
			if(!fieldSystemsArr[i])
			{
				continue;
			}
			var fieldName = fieldSystemsArr[i].fieldName;
			var systemName = fieldSystemsArr[i].fieldSystemName;
			if(fieldName)
			{
				var tempNode = {};
				var j = 0;
				for(; j < fieldNodes.length; ++j)
				{
					if(fieldNodes[j].text == fieldName)
					{
						if(systemName)
						{
							fieldNodes[j].children.push({
								text:systemName,
								children:[],
								nodeType:"fieldSystem"
							});
						}
						break;
					}
				}
				if(j == fieldNodes.length)
				{
					tempNode.text = fieldName;
					tempNode.nodeType = "field";
					tempNode.children = [];
					if(systemName)
					{
						tempNode.children.push({
							text:systemName,
							children:[],
							nodeType:"fieldSystem"
						});
					}
					fieldNodes.push(tempNode);
				}
			}
		}
		return fieldNodes;
	}
	
	//显示所属系统
	function onShowDetail(rowIndex) {
		var rowData = $('#datagrid').datagrid('getRows')[parseInt(rowIndex, 10)];
		$.ajax({
			type: "get",
			url: BASE_URL_USER_SEARCH + "/getFieldSystemRoot?id="+rowData.id,
			dataType:"json",
			contentType: "application/json",
			success: function(data) {
				//fieldSystems = data;
				
				var fieldSystemsNodes = getFieldSystemNodesFromArr(data);
				$("#sys_show_tt").tree("loadData", fieldSystemsNodes);
				$("#sys_show_tt > li > ul > li > .tree-node > .tree-file").css("background","url('../../images/st_folder.png') no-repeat 2px 2px");
				$("#system_show").window('setTitle',rowData.userCode + '所属系统');
				$('#system_show').window('open');
			},
			error: function() {
				$("#instance_save").linkbutton("enable");
				$("#instance_save .l-btn-text").text("保存");
				$.messager.alert('错误','<p>服务异常，修改用户授权信息失败，请稍后重试!</p>','error');
			}
		});		
	}
	
	function setChecked(sysName) {
		if(!sysName)
		{
			return;
		}
		$("#tt li .tree-node").each(function(){
			if($(".tree-title", $(this)).text() == sysName)
			{
				$('#tt').tree('check', this);
				return false;
			}
		});
		
	}
	
	function setCheckedList(sysNameArr)
	{
		if(sysNameArr && sysNameArr.length)
		{
			for(var i = 0, len = sysNameArr.length; i < len; ++i)
			{
				setChecked(sysNameArr[i]);
			}
		}
	}
	
	function choose_tree()
	{
		$('#tt').tree('expandAll');
		if(arrayLi.length == 0 && arrayLiInd == 0)
		{
			var searchVal = $("#systemName").val().toUpperCase(); 
			var row = $('#tt li .tree-node');  
			var rowcolumn = $('#tt li .tree-node > .tree-title');  
			var i = 0, j = 0;
			var offsetC = 0
			row.removeClass('tree-node-selected');  
			rowcolumn.each(function (column) {  
				var matchVal = $(this).text(); 
				if(matchVal.indexOf(searchVal) != -1)
				{
					i++;
					var panel_top = parseInt($(this).parents(".panel").css("top"), 10);
					
					if(i <= 1)
					{
						$(this).parent().addClass('tree-node-selected'); 
						var top = $(".tree_con").scrollTop() + $(this).offset().top - 76 - panel_top;
						$(".tree_con").scrollTop(top);
						arrayLiInd = 1;
					}			
					arrayLi.push([matchVal,$(".tree_con").scrollTop() + $(this).offset().top - 76 - panel_top]);
					
				}
				}); 
			}else
			{
				var rowcolumn = $('#tt li .tree-node > .tree-title'); 
				var row = $('#tt li .tree-node');  
				row.removeClass('tree-node-selected');
				
				if(arrayLiInd <  arrayLi.length)
				{
					rowcolumn.each(function (column) {  
						var matchVal = $(this).text(); 
						if(matchVal == arrayLi[arrayLiInd][0])
						{
							$(this).parent().addClass('tree-node-selected'); 
							$(".tree_con").scrollTop(arrayLi[arrayLiInd][1]);
							arrayLiInd++;
							return false;
						}
					});
				}else
				{
					//arrayLi = [];
					arrayLiInd = 0;
					$(".tree_con").scrollTop(0);
					choose_tree();
				}
			}
	}
</script>
</body>
</html>



